Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

it-pushable

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it-pushable

An iterable that you can push values into

  • 3.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

it-pushable

codecov CI

An iterable that you can push values into

About

An iterable that you can push values into.

Example

import { pushable } from 'it-pushable'

const source = pushable()

setTimeout(() => source.push('hello'), 100)
setTimeout(() => source.push('world'), 200)
setTimeout(() => source.end(), 300)

const start = Date.now()

for await (const value of source) {
  console.log(`got "${value}" after ${Date.now() - start}ms`)
}
console.log(`done after ${Date.now() - start}ms`)

// Output:
// got "hello" after 105ms
// got "world" after 207ms
// done after 309ms

Example

import { pushableV } from 'it-pushable'
import all from 'it-all'

const source = pushableV()

source.push(1)
source.push(2)
source.push(3)
source.end()

console.info(await all(source))

// Output:
// [ [1, 2, 3] ]

Table of contents

Install

$ npm i it-pushable

Browser <script> tag

Loading this module through a script tag will make it's exports available as ItPushable in the global namespace.

<script src="https://unpkg.com/it-pushable/dist/index.min.js"></script>

Usage

import { pushable } from 'it-pushable'

const source = pushable()

setTimeout(() => source.push('hello'), 100)
setTimeout(() => source.push('world'), 200)
setTimeout(() => source.end(), 300)

const start = Date.now()

for await (const value of source) {
  console.log(`got "${value}" after ${Date.now() - start}ms`)
}
console.log(`done after ${Date.now() - start}ms`)

/*
Output:
got "hello" after 105ms
got "world" after 207ms
done after 309ms
*/
import { pushableV } from 'it-pushable'
import all from 'it-all'

const source = pushableV()

source.push(1)
source.push(2)
source.push(3)
source.end()

console.info(await all(source))
/*
Output:
[ [1, 2, 3] ]
*/
  • it-pipe Utility to "pipe" async iterables together

API Docs

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Keywords

FAQs

Package last updated on 16 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc